home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ Oct 89 / Z0189-Re[2] A more useful-Oct89 < prev    next >
Encoding:
Text File  |  1989-10-26  |  1.6 KB  |  42 lines  |  [TEXT/GEOL]

  1. Item    1636699                         26-Oct-89        12:40
  2.  
  3. From:   ROSENSTEIN1                     Rosenstein, Larry
  4.  
  5. To:     MACAPP.TECH$                    MACAPP Tech
  6.  
  7. Sub:    Re: Re: A more useful IObject
  8.  
  9. I think IObject should be used for essential object initialization.  What I
  10. mean is the following:
  11.  
  12. To do failure handling properly, you have to do the following steps when
  13. initializing an object.
  14.  
  15. (1) Put the object in a state where it could be freed if the initialization
  16. failed.  This generally involves putting NIL in the various fields of the
  17. object.  (The Free method then uses FreeIfObject and DisposeIfHandle to free
  18. the data referenced by those fields.)
  19.  
  20. (2) Call the initialization method of your superclass.
  21.  
  22. (3) Do the rest of your initialization.
  23.  
  24. If your object can't initialize itself, then it should free itself so that the
  25. code that created the object doesn't have to.  (That's only one idea on how to
  26. handle this, but it seems the most convenient for programmers using your
  27. classes.)
  28.  
  29. If you follow that convention, then step 2 might fail, which would result in
  30. your object being freed.  That's why it is important that step 1 gets the
  31. object into a consistent state, and that step 1 does not fail.
  32.  
  33. As part of step 3, you should set up a failure handler, if any part of step 3
  34. could fail.  That handle should simply call Free.
  35.  
  36. IObject could be used to satisfy step 1, if it was called automatically when
  37. the object was created by New.  Since this generally involves setting fields to
  38. NIL, it is not necessary for IObject to have any parameters.
  39.  
  40. Larry Rosenstein
  41.  
  42.